<?php

define("GOOD_WORDS_CODE",       "good");
define("BAD_WORDS_CODE",        "bad");
define("SUGGESTED_WORDS_CODE",  "suggested");
define("SPELL_WORDS_CODE",      "spell");

class DpWordList
{
    private $_projectid;
    private $_ary;
    private $_code;
    private $_langcode;

    __construct($projectid, $code, $langcode)
    {
        $this->_projectid = $projectid;
        $this->_code = $code;
        $this->_langcode = $langcode;
    }

    private function file_name()
    {
        return "{$this->_langcode}.{$this->_code}.txt";
    }

    private function file_path()
    {
        return build_path(ProjectPath($this->_projectid),
                                    $this->file_name());
    }

    private function Save()
    {
        if(! isset($this->_ary))
            $this->_ary = array();
        file_put_contents($this->file_path(), 
                            serialize($this->_aray));
    }

    public function WordArray()
    {
        if(isset($this->_ary))
            return $this->_ary;

        $path = $this->file_path();
        if(! is_file($path))
        {
            $this->_ary = array();
            return $this->_ary;
        }
        return unserialize(file_get_contents($path));
    }

    private function WordList()
    {
        return implode("\n", $this->WordArray());
    }

    public function SubmitWordArray($words)
    {
    }
}
?>
